package jrmob.yonyou.com.commonlib.login.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

import jrmob.yonyou.com.commonlib.R;
import jrmob.yonyou.com.commonlib.baseui.base.BaseActivityMob_lib;


/**
 * 闪屏页面
 */
public class LoadingActivity_lib extends BaseActivityMob_lib {

    private View view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        view = View.inflate(this, R.layout.activity_loading_lib, null);
        setContentView(view);
        initData();
    }

    @Override
    public void initView() {

    }

    @Override
    public void initListener() {

    }

    /**
     * 初始化数据
     */
    public void initData() {
        startAnimation();
    }

    /**
     * 加载动画
     */
    private void startAnimation() {
        // TODO Auto-generated method stub
        // 动画初始化设置
        AlphaAnimation alpha = new AlphaAnimation(0.3f, 1.0f);
        alpha.setDuration(1000);

        // 动画监听界面
        alpha.setAnimationListener(new Animation.AnimationListener() {

            public void onAnimationEnd(Animation animation) {
                // 动画结束后，跳转到登录界面
                redirectToLogin();

            }

            public void onAnimationRepeat(Animation animation) {

            }

            public void onAnimationStart(Animation animation) {

            }
        });

        view.startAnimation(alpha);
    }

    /**
     * 跳转登录界面
     */
    private void redirectToLogin() {
        // TODO Auto-generated method stub
        // 跳转至主界面，并结束当前界面
        Intent intent = new Intent(this, LoginBaseActivity_lib.class);
        startActivity(intent);
        finish();
    }


}
